﻿//EChart
var $OperationBoardTable = {
    DealUrl: function (vueApp, url, type, param) {
        var my = vueApp;
        switch (url) {

            ////获取Input数据
            case '/api/OperationBoard/get': Mock.mock(host + url, type, function (options) {
                console.log("uuuuuu");
                var p = JSON.parse(options.body);
                var result = {};
                var legend = [];
                var legend2 = [];
                var legend3 = [];
                var data = [];
                var data2 = [];
                var data3 = [];
                console.log(p.model.type)
                switch (p.model.type) {
                    case "RiskCategory":
                        result = {
                            title: "九种特殊作业数量饼状图展示",
                            title2: "隐患分类数量饼状展示",
                            title3: "隐患等级数量饼状展示",

                            subtext: '数据',
                            legend: ['动火', '受限空间', '盲板抽堵', '高处', '吊装', '临时用电', '动土', '断路', '管线打开'],
                            legend2: ['动火', '受限空间'],
                            legend3: ['动火', '受限空间', '盲板抽堵', '高处'],

                            data: [
                                {
                                    value: Math.floor(Math.random() * 500),
                                    name: '动火'
                                },
                                {
                                    value: Math.floor(Math.random() * 500),
                                    name: '受限空间'
                                },
                                {
                                    value: Math.floor(Math.random() * 500),
                                    name: '盲板抽堵'
                                },
                                {
                                    value: Math.floor(Math.random() * 500),
                                    name: '高处'
                                },
                                {
                                    value: Math.floor(Math.random() * 500),
                                    name: '吊装'
                                }

                                ,
                                {
                                    value: Math.floor(Math.random() * 500),
                                    name: '临时用电'
                                }

                                ,
                                {
                                    value: Math.floor(Math.random() * 500),
                                    name: '动土'
                                }

                                ,
                                {
                                    value: Math.floor(Math.random() * 500),
                                    name: '断路'
                                }
                                ,
                                {
                                    value: Math.floor(Math.random() * 500),
                                    name: '管线打开'
                                }
                            ],

                            data2: [
                                {
                                    value: Math.floor(Math.random() * 500),
                                    name: '动火'
                                },
                                {
                                    value: Math.floor(Math.random() * 500),
                                    name: '受限空间'
                                }
                            ],
                            data3: [
                                {
                                    value: Math.floor(Math.random() * 500),
                                    name: '动火'
                                },
                                {
                                    value: Math.floor(Math.random() * 500),
                                    name: '受限空间'
                                },
                                {
                                    value: Math.floor(Math.random() * 500),
                                    name: '盲板抽堵'
                                },
                                {
                                    value: Math.floor(Math.random() * 500),
                                    name: '高处'
                                }
                            ]

                        };
                        break;
                    case "RiskDepartment":
                        DicCode.forEach(function (v, i) {
                            if (v.code == '14') {
                                v.data.forEach(function (vv, i) {
                                    legend.push(vv.value);
                                    data.push({
                                        value: Math.floor(Math.random() * 500),
                                        name: vv.value
                                    })
                                })
                            }
                        })
                        result = {
                            title: "隐患部门饼状图",
                            subtext: '隐患部门',
                            legend: legend,
                            data: data
                        };
                        break;
                    case "RiskFactory":
                        result = {
                            title: "隐患工厂饼状图",
                            subtext: '隐患工厂',
                            legend: ['A工厂', 'B工厂', 'C工厂', 'D工厂', 'E工厂'],
                            data: [
                                {
                                    value: Math.floor(Math.random() * 500),
                                    name: 'A工厂'
                                },
                                {
                                    value: Math.floor(Math.random() * 500),
                                    name: 'B工厂'
                                },
                                {
                                    value: Math.floor(Math.random() * 500),
                                    name: 'C工厂'
                                },
                                {
                                    value: Math.floor(Math.random() * 500),
                                    name: 'D工厂'
                                },
                                {
                                    value: Math.floor(Math.random() * 500),
                                    name: 'E工厂'
                                }
                            ]
                        };
                        break;
                    case "RiskLevel":
                        DicCode.forEach(function (v, i) {
                            if (v.code == '03') {
                                v.data.forEach(function (vv, i) {
                                    legend.push(vv.value);
                                    data.push({
                                        value: Math.floor(Math.random() * 500),
                                        name: vv.value
                                    })
                                })
                            }
                        })
                        result = {
                            title: "隐患级别饼状图",
                            subtext: '隐患级别',
                            legend: legend,
                            data: data
                        };
                        break;
                    case "RiskTrendLine":
                        break;
                    default:
                        break;
                }
                return {
                    result: "Success", message: null,
                    data: result
                };
            }); break;
        }
    },
    List: [],
    InitArray: function () {
        for (var i = 0; i < 80; i++) {
            $OperationBoardTable.List.push(Mock.mock({
                id: Mock.Random.id(),//序号
                JobSteps: randomKey("21"),//作业步骤
                Task: randomKey("24"),//工作任务
                CheckStandard: Mock.mock('@cparagraph(1, 3)'),//检查标准
                RiskOfViolation: Mock.mock('@cparagraph(1, 3)'),//违反标准的风险
                RiskLevel: randomKey('03'),//风险等级
                TreeNode: randomTreeNode(myTree)
            }));

        }
    }
}